<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        div{padding:10px;margin:10px;border:solid 1px black;}
    </style>
</head>
<body>
    <div class="app">
        <h1>这是 - {{title}}</h1>

        <Child1 :tit="title" abc="123" :num="365" qwe="hello" :asd="true" :zxc="[1,2,3]" :msg="function(){}"></Child1>

        <Child2 :flag="true" msg=""></Child2>
    </div>
</body>
<template id="child1Temp">
    <div>
        <h3>这是 - {{title}}</h3>
        <p>父组件传来的了：{{abc}} - {{typeof abc}}</p>
        <p>父组件传来的了：{{num}} - {{typeof num}}</p>
        <p>父组件传来的了：{{qwe}} - {{typeof qwe}}</p>
        <p>父组件传来的了：{{asd}} - {{typeof asd}}</p>
        <p>父组件传来的了：{{zxc}} - {{typeof zxc}}</p>
        <p>父组件传来的了：{{msg}} - {{typeof msg}}</p>
        <p>父组件传来的了：{{tit}} - {{typeof tit}}</p>
    </div>
</template>
<template id="child2Temp">
    <div>
        <h3>这是 - {{title}}</h3>
        <p>父组件传来的了：{{str}} - {{typeof str}}</p>
        <p>父组件传来的了：{{flag}} - {{typeof flag}}</p>
        <p>父组件传来的了：{{msg}} - {{typeof msg}}</p>
    </div>
</template>
<script src="../vue.global.js"></script>
<script>
    const app = Vue.createApp({
        data(){
            return {
                title:"根组件"
            }
        },
        components:{
            Child1: {
                data(){
                    return {
                        title:"子组件1"
                    }
                },
                template:"#child1Temp",
                props: ["abc", "qwe", "asd", "zxc", "msg", "tit", "num", "str"]
            },
            Child2: {
                data(){
                    return {
                        title:"子组件2"
                    }
                },
                template:"#child2Temp",
                props: {
                    str: {
                        default: "hello child"
                    },
                    flag: {
                        type: Boolean
                    },
                    msg: {
                        required: true
                    }
                }
            }
        }
    })

    app.mount(".app");

</script>
</html>